#include <iostream>
#include <memory>

using namespace std;

class FakeString{
public:
	explicit FakeString(const char* str): _str(str){
		cout << "Constructor for FakeString: " << _str  << endl;
	}

	~FakeString(){
		cout << "DeConstructor For FakeString: " << _str << endl;
	}

    FakeString(FakeString&) = delete;
    FakeString& operator=(FakeString&)=delete;
private:
	const char* _str;
};

void test_unique_ptr() {
	std::unique_ptr<FakeString> x = std::make_unique<FakeString>("original x");
	x = std::make_unique<FakeString>("new x");
	cout << "sizeof(x) == sizeof(FakeString*): " << (sizeof(x) == sizeof(FakeString*)) << endl;
}

void test_unique_ptr_copy() {
	auto x = std::make_unique<FakeString>("copy x");
	auto y = std::make_unique<FakeString>("copy y");
//	cout << "before move, x " << x << endl;
//	cout << "before move, y " << y << endl;
	x = std::move(y);
//	cout << "after move: x " << x << endl;
//	cout << "after move: y " << y << endl;
}

void passShared_ptr(std::shared_ptr<FakeString> sharedPtr){
    cout << "pass shared ptr: " << sharedPtr << endl;
}

void test_shared_ptr() {
    auto x = std::make_shared<FakeString>("SharedX");
    passShared_ptr(x);
}

int main() {
    test_shared_ptr();
}


